<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>频道搜索</title>
    <%@ include file="/common/meta.jsp" %>
    <%@ include file="/common/public_input.jsp" %>
    <script type="text/javascript" src="${ctx}/js/validate/jquery.validate.js"></script>
    <script type="text/javascript" src="${ctx}/js/validate/messages_cn.js"></script>
    <script>
        $(function () {
            $(".flexigrid").flexigrid({
                height: "auto",
                colModel : [
                    {display: '一级分类', name : 'tag1', width : 200, sortable : false, align: 'center', hide : false},
                    {display: '二级分类', name : 'tag2', width : 200, sortable : false, align: 'center', hide : false},

                    {display: '创建时间', name : 'addTime', width : 200, sortable : false, align : 'center'}
                ],
                checkbox: false,
                usepager: false
            });
            $(".flexigrid2").flexigrid({
                height: "auto",
                colModel: [
                    {display: 'UUID', name: 'uuid', width: 250, sortable: false, align: 'center', hide: false},
                    {display: '图片类型', name: 'format', width: 70, sortable: false, align: 'center'},
                    {display: '图片高', name: 'height', width: 70, sortable: false, align: 'center'},
                    {display: '图片宽', name: 'width', width: 70, sortable: false, align: 'center'},
                    {display: '图片地址', name: 'url', width: 450, sortable: false, align: 'center'},
                    {display: '添加时间', name: 'addTime', width: 120, sortable: false, align: 'center'}
                ],
                checkbox: false,
                usepager: false
            });
            $(".flexigrid3").flexigrid({
                height: "auto",
                colModel : [
                    {display: 'ID', name : 'id', width : 70, sortable : false, align: 'center', hide : false},
                    {display: '直播频道ID', name : 'fatherId', width : 70, sortable : false, align : 'center'},
                    {display: '流名称', name : 'streamName', width : 70, sortable : false, align : 'center'},
                    {display: '流类型', name : 'streamType', width : 70, sortable : false, align : 'center'},
                    {display: '码流', name : 'bitRate', width : 70, sortable : false, align : 'center'},
                    {display: '画面比例', name : 'aspectRatio', width : 70, sortable : false, align : 'center'},
                    {display: '画面尺寸', name : 'screenSize', width : 70, sortable : false, align : 'center'},
                    {display: '添加时间', name : 'addTime', width : 120, sortable : false, align : 'center'},
                    {display: '最后更新时间', name : 'updateTime', width : 120, sortable : false, align : 'center'}
                ],
                checkbox: false,
                usepager: false
            });
            $(".reservation").flexigrid({
                height: "auto",
                colModel : [
                    {display: 'id', name : 'id', width : 70, sortable : false, align: 'center', hide : false},
                    {display: 'type', name : 'type', width : 70, sortable : false, align : 'center'},
                    {display: 'content', name : 'content', width : 120, sortable : false, align : 'center'},
                    {display: 'onlineTime', name : 'onlineTime', width : 90, sortable : false, align : 'center'},
                    {display: 'offlineTime', name : 'offlineTime', width : 90, sortable : false, align : 'center'},
                    {display: 'startDay', name : 'startDay', width : 70, sortable : false, align : 'center'},
                    {display: 'endDay', name : 'endDay', width : 70, sortable : false, align : 'center'},
                    {display: 'reason', name : 'reason', width : 70, sortable : false, align : 'center'},
                    {display: 'status', name : 'status', width : 70, sortable : false, align : 'center'},
                    {display: 'addTime', name : 'addTime', width : 120, sortable : false, align : 'center'},
                    {display: 'updateTime', name : 'updateTime', width : 120, sortable : false, align : 'center'},
                    {display: '', name : 'delButton', width : 70, sortable : false, align : 'center'}
                ],
                checkbox: false,
                usepager: false
            });
        });

    </script>
    <s:include value="/WEB-INF/content/program/program/program-js.jsp" />
    <s:include value="/WEB-INF/content/stream/stream/stream-js.jsp" />
    <s:include value="/WEB-INF/content/stream/liveStream/liveStream-js.jsp" />
    <s:include value="/WEB-INF/content/reservation/reservation/reservation-js.jsp" />
    <style>
    ul.location {margin-left: 20px;}
    ul.location li {float: left; width: 90px;}
    </style>
</head>

<body>
<div style="padding: 10px;">
    <h3 style="padding: 0px; margin: 0px;">频道信息查询</h3>

    <form id="inputForm" method="get">
        <table class="noborder">
            <tr>
                <td>频道ID:</td>
                <td>
                    <s:textfield name="id" maxLength="10" value="%{id}"/>
                </td>
                <td>
                    <security:authorize ifAnyGranted="AUTH_MANAGER_AUTH,AUTH_ALL">
                        <input class="button" type="submit" value="搜索"/>&nbsp;
                    </security:authorize>
                </td>
            </tr>
        </table>
    </form>
</div>

<div class="div-tabs-nav">
    <ul class="ui-tabs-nav">
        <li class="ui-tabs-selected">收费信息</li>
        <li>LOGO信息</li>
        <li>大小写分类信息</li>
        <li>节目表信息</li>
        <li>直播流信息</li>
        <li>直播流扩展信息</li>
        <li>平台播控信息</li>
        <li>预约上下线信息</li>
    </ul>
</div>
<c:if test="${not empty id}">
<div class="ui-tabs-panel">
    <table>
        <tbody>
        <tr>
            <td>是否付费：<s:property
                    value="@com.iqiyi.pps.epg.core.model.channel.ChannelBoss@MEMEBER_FREE_MAP.get(channelBoss.isMemeberFree)"/></td>
        </tr>
        <tr>
            <td>会员视频：<s:property
                    value="@com.iqiyi.pps.epg.core.model.channel.ChannelBoss@MEMBER_ONLY_MAP.get(channelBoss.isMemberOnly)"/></td>
        </tr>
        <tr>
            <td>划价状态：<s:property
                    value="@com.iqiyi.pps.epg.core.model.channel.ChannelBoss@STATUS_MAP.get(channelBoss.status)"/></td>
        </tr>
        <c:if test="${channelBoss.isMemeberFree < 1}">
            <tr>
                <td>开始时间：<s:date name="channelBoss.paidStartTime" format="yyyy-MM-dd HH:mm:ss"/></td>
            </tr>
            <tr>
                <td>结束时间：<s:date name="channelBoss.paidEndTime" format="yyyy-MM-dd HH:mm:ss"/></td>
            </tr>
        </c:if>
        </tbody>
    </table>
</div>
<div class="ui-tabs-panel ui-tabs-hide">
    <table class="flexigrid2">
        <tbody>
        <s:iterator value="channelLogo" id="entity">
            <tr>
                <td><s:property value="#entity.uuid"/></td>
                <td><s:property value="#entity.format"/></td>
                <td><s:property value="#entity.height"/></td>
                <td><s:property value="#entity.width"/></td>
                <td><a target="_blank" href="<s:property value="#entity.url" />"><img height="25px" src="<s:property value="#entity.url" />" /></a></td>

                <td><s:date name="#entity.addTime" format="yyyy-MM-dd HH:mm:ss"/></td>
            </tr>
        </s:iterator>
        </tbody>
    </table>
</div>
<div class="ui-tabs-panel ui-tabs-hide">
    <table class="flexigrid">
        <tbody>
        <s:iterator value="channelTag" id="entity">
            <tr>
                <td><s:property value="#entity.tagOne" /></td>
                <td><s:property value="#entity.tagTwo" /></td>
                <td><s:property value="#entity.addTime" /></td>
            </tr>
        </s:iterator>
        </tbody>
    </table>
</div>
<div class="ui-tabs-panel ui-tabs-hide">

    <table id="programTable" style="display: none">
        <tbody></tbody>
    </table>
</div>
<div class="ui-tabs-panel ui-tabs-hide">

    <table id="streamTable" style="display: none">
        <tbody>
        </tbody>
    </table>
</div>
<div class="ui-tabs-panel ui-tabs-hide">

    <table id="liveStreamTable" style="display: none">
        <tbody>
        </tbody>
    </table>
</div>
<div class="ui-tabs-panel ui-tabs-hide">
    <div id="platform">
        <p>√表示”是“，否者为”否“。平台类型未打√的是还未设置播控信息，已√的为设置过的，且不可删除，可设置上线下线状态。</p>
        <input type="button" value="保存" onclick="savePlatform()" />
        <s:iterator value="platformList" id="entity" status="u">
        <div style="margin-top: 12px;">
            <div style="margin-bottom: 7px;">
                <label style="width: 220px; display: inline-block;"><input type="checkbox" name="platform" value="<s:property value="#entity.platformKey" />"<s:if test="#entity.isChecked == 1"> checked</s:if> /> <s:property value="#entity.platform" /></label>
                <label><input type="radio" name="availableStatus<s:property value="#u.index" />" value="true"<s:if test="#entity.availableStatus != 0"> checked</s:if> /> 上线</label>
                <label><input type="radio" name="availableStatus<s:property value="#u.index" />" value="false"<s:if test="#entity.availableStatus == 0"> checked</s:if> /> 下线</label>
                <label>延时：<input type="text" name="liveDelayTime" value="<s:property value="#entity.liveDelayTime" />" size="8" />秒</label>
            </div>
            <ul class="location">
                <s:if test="blacklist[#entity.platformKey]!=null">
                    <s:set value="blacklist[#entity.platformKey]" var="bl" />
                    <s:iterator value="locationConfigList" id="item">
                        <li><label><input type="checkbox" name="blacklist" value="<s:property value="#item.key" />"<s:if test="#bl.contains(#item.key)"> checked="checked"</s:if> /><s:property value="#item.descr" /></label></li>
                    </s:iterator>
                </s:if>
                <s:else>
                    <s:iterator value="locationConfigList" id="item">
                    <li><label><input type="checkbox" name="blacklist" value="<s:property value="#item.key" />" /><s:property value="#item.descr" /></label></li>
                    </s:iterator>
                </s:else>
            </ul>
            <p style="clear:both;"></p>
        </div>
        </s:iterator>
    </div>
</div>
<div class="ui-tabs-panel ui-tabs-hide">
    <table id="reservationTable" style="display: none;">
        <tbody></tbody>
    </table>
    <div class="sDiv2">
        频道ID: <input class="qsbox" type="text" name="filter_EQL_fatherId" value="${param.id}" size="9" readonly="true" />
        状态: <s:select cssClass="qsbox" name="filter_EQI_status" list="@com.iqiyi.pps.epg.core.model.reservation.ReserveControl@STATUS_MAP" headerKey="" headerValue="全部" />&nbsp;
        <input type="button" value="清除">
        <input type="button" value="搜索">
    </div>
</div>
</c:if>
<script>
var id = $("#id").val();
var host = "<s:property value="apiHost" />";
$.ajaxSetup({
    beforeSend: function(xhr) {
        xhr.setRequestHeader("From", "show");
        xhr.setRequestHeader("Time", Math.round(new Date().getTime() / 1000));
        xhr.setRequestHeader("Sign", "#f93Uc31K24()_@");
    }
});
//function saveLocation() {
//    var data = [];
//    $("#location input[name=location]:checked").each(function() {
//        var d = {};
//        d["location"] = $(this).val();
//        data.push(d);
//    });
//    $.ajax({
//        url : host + "/broadcast/control?callback=jsonp",
//        type : "POST",
//        data : {"channelId": id, "params": JSON.stringify(data)},
//        dataType : "jsonp",
//        jsonpCallback : "jsonp",
//        success : function(jsonObj, textStatus, xhr) {
//            if (jsonObj.code == "A00000") {
//                alert("设置成功");
//            } else {
//                alert(jsonObj.msg);
//            }
//        },
//        error : function(xhr, textStatus, errorThrown) {
//            console.log("HTTP Status: " + xhr.status);
//            console.log("Error textStatus: " + textStatus);
//            console.log("Error thrown: " + errorThrown);
//            alert("error");
//        }
//    });
//}
function savePlatform() {
    var data = [];
    $("#platform input[name=platform]:checked").each(function () {
        var d = {};
        var obj = $(this).parent().parent().parent();
        d[$(this).attr("name")] = $(this).val();
        d["availableStatus"] = obj.find("input[type=radio]:checked").val();
        d["liveDelayTime"] = obj.find("input[type=text]").val();
        d["blacklist"] = "";
        obj.find("ul input[type=checkbox]:checked").each(function() {
            d["blacklist"] += $(this).val() + ",";
        });
        data.push(d);
    });
    $.ajax({
        url: host + "/broadcast/control?callback=jsonp",
        type: "POST",
        data: {"channelId": id, "params": JSON.stringify(data)},
        dataType: "jsonp",
        jsonpCallback: "jsonp",
        success: function (jsonObj, textStatus, xhr) {
            if (jsonObj.code == "A00000") {
                alert("设置成功");
            } else {
                alert(jsonObj.msg);
            }
        },
        error: function (xhr, textStatus, errorThrown) {
            console.log("HTTP Status: " + xhr.status);
            console.log("Error textStatus: " + textStatus);
            console.log("Error thrown: " + errorThrown);
            alert("error");
        }
    });
}
function delReservation(id, obj) {
    $.ajax({
        url: host + "/reservation/del?callback=jsonp",
        type: "POST",
        data: {"id": id},
        dataType: "jsonp",
        jsonpCallback: "jsonp",
        success: function (jsonObj, textStatus, xhr) {
            if (jsonObj.code == "A00000") {
                $(obj).parent().parent().parent().remove();
            } else {
                alert(jsonObj.msg);
            }
        },
        error: function (xhr, textStatus, errorThrown) {
            console.log("HTTP Status: " + xhr.status);
            console.log("Error textStatus: " + textStatus);
            console.log("Error thrown: " + errorThrown);
            alert("error");
        }
    });
}
</script>

</body>
</html>

